package com.lijian.search.controller;

import java.io.IOException;

import org.apache.solr.client.solrj.SolrServerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lijian.common.utils.ExceptionUtil;
import com.lijian.common.utils.TaotaoResult;
import com.lijian.search.service.ItemService;

/**
 * <p>Title: ItemController.java</p>
 * <p>Description: 导入商品数据到 solr </p>
 * <p>Copyright: Copyright (c) 2017</p>
 * @author lijian
 * @date 2017年4月16日下午8:46:14
 * @version 1.0
 */
@Controller
public class ItemController {

	@Autowired
	private ItemService itemService;
	
	@RequestMapping("/importAll")
	@ResponseBody
	public TaotaoResult importAll(){
		try {
			return itemService.importItems();
		} catch (SolrServerException | IOException e) {
			e.printStackTrace();
			return TaotaoResult.build(500, ExceptionUtil.getStackTrace(e));
		}
	}
}
